<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        body {
            display: grid;
            place-items: center;
            /* 同时水平和垂直居中 */
            height: 100vh;
        }

        canvas {
            border: 1px solid black;
        }
    </style>
</head>

<body>
    <script type="module" src="./canvas.ts"></script>
    <script>
        window.onload = function () {
            draw();
        }

        function createCanvas() {
            const canvas = document.createElement('canvas');
            canvas.width = 500;
            canvas.height = 500;
            document.body.appendChild(canvas);
            const ctx = canvas.getContext('2d');
            if (ctx === null) {
                throw new Error('ctx is null');
            }
            return ctx;
        }
        function draw() {
            const ctx = createCanvas();

            ctx.beginPath();
            ctx.arc(100, 50, 40, 0, 2 * Math.PI); 
            ctx.stroke(); // 仅勾勒椭圆轮廓

        }
    </script>
</body>

</html>